package org.thinkinbunny.financial.broadcast;

import org.thinkinbunny.financial.R;
import org.thinkinbunny.financial.activity.BudgetActivity;

import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class BudgetReciver extends BroadcastReceiver {
	Context context;
	public static int NOTIFICATION_ID = 21321;
	public String message="";
	public static String ACTION="org.thinkinbunny.financial.broadcast.BudgetReciver";
	@Override
	public void onReceive(Context context, Intent intent) {
		this.context = context;
		message=intent.getStringExtra("message");
		showNotification();
	}

	private void showNotification() {

		NotificationManager notificationManager = (NotificationManager) context
				.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
		Notification notification = new Notification(R.drawable.ic_launcher,
				context.getString(R.string.app_name)+message, System.currentTimeMillis());

		PendingIntent contentIntent = PendingIntent.getActivity(context, 0,
				new Intent(context, BudgetActivity.class), 0);
		notification.setLatestEventInfo(context, context.getString(R.string.app_name)+message, null,
				contentIntent);
		notificationManager.notify(NOTIFICATION_ID, notification);
	}
}
